<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
<title>数据字典${ctx}</title>
</head>
<script type="text/javascript" src="${ctx}/scripts/ext2.2.1/adapter/ext/ext-base.js" charset="UTF-8"></script>
<script type="text/javascript" src="${ctx}/scripts/ext2.2.1/ext-all-debug.js" charset="UTF-8"></script>
<script type="text/javascript" src="${ctx}scripts/ext2.2.1/source/locale/ext-lang-zh_CN.js" charset="UTF-8"></script>
<script type="text/javascript">
/*
Ext.onReady(function() {
    var Tree = Ext.tree;
    var tree = new Tree.TreePanel( {
          el : 'tree-div',//目标div容器
          autoScroll : true,
          animate : true,
          enableDD : true,
          containerScroll : true,
          loader : new Tree.TreeLoader( {
                dataUrl : '/system/dictionaryGeneratorNode.action'// dictionaryGeneratorNode.action就是要动态载入数据的请求地址，这里请求时会提交一个参数为node的值，值为root即new Tree.AsyncTreeNode()对象的id值
          })
    });

    var root = new Tree.AsyncTreeNode( {
          text : '组织机构树',
          draggable : false,
          id : '-100'//默认的node值：?node=-100
    });
    tree.setRootNode(root);
    tree.render();
    root.expand();

});
*/


Ext.onReady(function(){
    tree = new Ext.tree.TreePanel('users', {
        animate:true,
        enableDD:false,
        loader: new Ext.tree.TreeLoader(), // Note: no dataurl, register a TreeLoader to make use of createNode()
        lines: true,
        selModel: new Ext.tree.MultiSelectionModel(),
        containerScroll: false
    });
 
    var users_json = [{
        onclick: "new Ajax.Request('http://domain/users/1.js', {asynchronous:true, evalScripts:true, method:'get'}); false;", 
        cls: "file", 
        text: "Forename Surname", 
        id: "user_1", 
        leaf: true
    }];
 
   // set the root node
    var root = new Ext.tree.AsyncTreeNode({
        text: 'Users',
        draggable:false,
        id:'source',
        children: users_json
    });
 
    tree.setRootNode(root);
 
    tree.on('click', function(n){
      if(n.isLeaf() && n.attributes.onclick){
        eval(n.attributes.onclick);
      }
    });
 
    tree.render();
    root.expand();
});
</script>

<body>
<div id="tree-div" ></div>
</body>
</html>
